package factory.simple.pizzastore.order;

import factory.simple.pizzastore.pizza.CheesePizza;
import factory.simple.pizzastore.pizza.GreekPizza;
import factory.simple.pizzastore.pizza.Pizza;

/**
 * @author shenhan
 * @create 2020/3/19 16:34
 * @description 简单工厂类
 */
public class PizzaFactory {
    public Pizza createPizza(String type) {
        System.out.println("使用简单工厂模式");
        Pizza pizza = null;
        if ("greek".equals(type)) {
            pizza = new GreekPizza();
            pizza.setName("greek");
        } else if ("cheese".equals(type)) {
            pizza = new CheesePizza();
            pizza.setName("cheese");
        } else {
            return null;
        }
        return pizza;
    }
}
